<template>
	<view class="page-index">
		<view class="sticky">
			<view class="item1" v-if="Type==1">
				<view class="call" v-if="friend.is_phone==1" @click="call()">
					<image src="/static/news/call.png" mode=""></image>
					<view class="text">打电话</view>
				</view>
				<view class="call" v-if="friend.is_phone==0">
					<image src="/static/news/callno.png" mode=""></image>
					<view class="text">打电话</view>
				</view>
				<view class="call" v-if="friend.is_closure==0" @click="lookResume()">
					<image src="/static/news/resume.png" mode=""></image>
					<view class="text">查看接单</view>
				</view>
				<view class="call" v-if="friend.is_closure==1" @click="lookResume()">
					<image src="/static/news/resumeno.png" mode=""></image>
					<view class="text">查看接单</view>
				</view>
				<view class="call" v-if="friend.is_collect==1" @click="collect()">
					<image src="/static/news/collect.png" mode=""></image>
					<view class="text">收藏</view>
				</view>
				<view class="call" v-if="friend.is_collect==0" @click="collect()">
					<image src="/static/news/collectno.png" mode=""></image>
					<view class="text">收藏</view>
				</view>
				<view class="call" @click="report()">
					<image src="/static/index/jubao.png" mode=""></image>
					<view class="text">举报</view>
				</view>
			</view>
			<view class="item1" v-if="Type==0">
				<view class="call" v-if="friend.is_phone==1" @click="call()">
					<image src="/static/news/call.png" mode=""></image>
					<view class="text">打电话</view>
				</view>
				<view class="call" v-if="friend.is_phone==0">
					<image src="/static/news/callno.png" mode=""></image>
					<view class="text">打电话</view>
				</view>
				<view class="call" @click="sendResume()">
					<image src="/static/news/resume.png" mode=""></image>
					<view class="text">发接单</view>
				</view>
				<view class="call" @click="report()">
					<image src="/static/index/jubao.png" mode=""></image>
					<view class="text">举报</view>
				</view>
			</view>
		</view>
		<!-- 消息 -->
		<view class="messages-box" :style="{'padding-bottom': boxHeight+chatHeight+'px','padding-top':stickyHeight}" @click="closeAll()">
			<view class="message" v-for="(item,index) in messages" :key="index" @longpress="longpress(index)">
				<view class="time">{{ transferTime(item.timestamp)}}</view>
				<!-- 撤回 -->
				<view class="message-recalled" v-if="item.recalled">
					<view v-if="item.senderId !== currentUser.id" class="message-recalled-self">
						<view>你撤回了一条消息</view>
						<span v-if="item.type === 'text' && Date.now()-item.timestamp< 60 * 1000 " @click="editRecalledMessage(item.payload.text)">重新编辑</span>
					</view>
					<view v-else>{{friend.nickname}}撤回了一条消息</view>
				</view>
				<!-- 自己 -->
				<view class="myMessage" v-if="item.senderId == currentUser.id&&item.type=='text'&&!item.recalled">
					<view class="bubble">
						{{item.payload.text}}
						<view v-if="backIndex == index" class="popupcss">
							<text v-if="item.type=='text'" @click="fuzhi(item)">复制</text>
							<view class="xiancss" v-if="item.type=='text'"></view>
							<text @click="cehui(item)">撤回</text>
						</view>
					</view>
					<image :src="currentUser.head" class="avatar"></image>
				</view>
				<!-- 对方 -->
				<view class="otherMessage" v-if="item.senderId != currentUser.id&&item.type=='text'&&!item.recalled">
					<image :src="friend.avatar" class="avatar"></image>
					<view class="bubble">
						{{item.payload.text}}
						<view v-if="backIndex == index" class="popupcss">
							<text v-if="item.type=='text'" @click="fuzhi(item)">复制</text>
						</view>
					</view>
				</view>
				<!-- 图片消息 -->
				<view class="myMessage" v-if="item.senderId != friend.uuid&&item.type=='image'">
					<image :src="item.payload.url" mode="widthFix" class="newsimage" @click="imageSee(item)"></image>
					<image :src="currentUser.head" class="avatar"></image>
				</view>
				<!-- 对方 -->
				<view class="otherMessage" v-if="item.senderId == friend.uuid&&item.type=='image'">
					<image :src="friend.avatar" class="avatar"></image>
					<image :src="item.payload.url" mode="widthFix" class="newsimage" @click="imageSee(item)"></image>
				</view>
				<!-- 需求消息 -->
				<view class="requirement-box" v-if="item.type=='positions'" @click="goPosition(item)">
					<view class="item1">
						<view class="position">{{item.payload.title}}</view>
						<view class="salary">{{item.payload.stitle}}</view>
					</view>
					<view class="item2">
						{{item.payload.company.name}}
					</view>
					<view class="item3">
						<view class="exp">{{item.payload.age.title}}</view>
						<view class="exp">{{item.payload.drving.title}}</view>
						<view class="exp">{{item.payload.areas.title}}</view>
					</view>
					<text decode="true" class="item4">
						{{beautify_time(item.timestamp)?beautify_time(item.timestamp):'刚刚'}}
					</text>
					<view class="item6">
					</view>
				</view>
				<!-- 打招呼消息 -->
				<view class="position" v-if="item.type=='custom'" style="margin-top: 40rpx;" @click="customs(item)">
					<text class="name">沟通需求:</text>
					<text class="title">{{item.payload.title}}</text>
				</view>
				<!-- 接单消息 -->
				<view class="resume-box" v-if="item.type=='resumes'" @click="goResume(item)">
					<view class="top-box">
						<image :src="item.payload.head" mode=""></image>
						<view class="right-box">
							<view class="valuebox">
								<view class="name">
									期望:{{item.payload.type_text.join()}}
								</view>
								<view class="value">
									{{item.payload.age_text}} | {{item.payload.drving_text}} |
									{{item.payload.areas_text}}
								</view>
							</view>
							<view class="salary">
								{{item.payload.salary}}
							</view>
						</view>
					</view>
					<view class="bottom-box">
						<view class="bottom-item" v-for="(items,index) in item.payload.experienceList" :key="index">
							<image src="/static/news/news.png"></image>
							<view class="value">
								{{items.company}}·{{items.position}}
								<!-- {{item}} -->
							</view>
						</view>
						<view class="bottom-item" v-for="(items,index) in item.payload.school" :key="index">
							<image src="/static/news/scool.png"></image>
							<view class="value">
								{{items.name}}·{{items.profession}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部输入框 -->
		<view class="chat-box" :style="{'padding-bottom': height}">
			<view class="chat">
				<view class="words" @click="quickShow()">
					常用语
				</view>
				<input type="text" class="chats" :adjust-position="false" :confirm-hold='hold' v-model="content" :focus='focu' @blur="poinblur" @confirm='createTextMessage()' confirm-type='send' @focus="focus" :cursor='content.length'>
				<view class="tips">
					<image src="/static/news/expression.png" @click="emojiClick()"></image>
					<image src="/static/news/add.png" @click="add()"></image>
				</view>
			</view>
			<view class="addbox" v-if="addshow">
				<view class="box-list" v-if="status==0">
					<view class="image-box" @click="createImageMessage()">
						<image src="/static/news/tupian.png" mode=""></image>
						<view>
							图片
						</view>
					</view>
					<view class="image-box" @click="zhiweiBnt()" v-if="Type==1">
						<image src="/static/news/zhiwei.png" mode=""></image>
						<view>
							需求
						</view>
					</view>
				</view>
				<view class="position-box">
					<view class="positionList" v-for="(item,index) in positionList" :key="index" v-if="status==1">
						<view class="title">
							{{item.title}}
						</view>
						<view class="send" @click="sendPosition(item)">
							发送
						</view>
					</view>
				</view>
				<view class="quick-box" v-if="status == 2 ||status ==3">
					<scroll-view scroll-y="true" class="scroll-box">
						<view class="quick-list" v-for="(item,index) in quickList" :key="index">
							<view class="text" @click="quickText(item)">
								{{item.txt}}
							</view>
							<view class="handle" v-if="status ==3">
								<image src="/static/news/delete.png" @click="deleteQuick(item)"></image>
								<image src="/static/news/edit.png" @click="editQuick(item)"></image>
							</view>
						</view>
					</scroll-view>
					<view class="caozuo">
						<view class="add" @click="addQuick()">
							添加
						</view>
						<view class="add" @click="manage()">
							管理
						</view>
					</view>
				</view>
				<view class="emoji-box" v-if="status ==4">
					<view class="item">
						<view class="emoji" v-for="(item,index) in emojiData[0]" :key="index" @click="pushEmoji(item)">
							{{item}}
						</view>
					</view>
					<view class="send-box">
						<view class="send" @click="createTextMessage()">
							发送
						</view>
					</view>
				</view>
			</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="textarea-box">
				<view class="title">
					编辑常用语
				</view>
				<textarea placeholder='添加常用语' class="textarea" v-model="textForm.txt" mask-click='false'></textarea>
				<view class="choice">
					<view class="close" @click="close()">
						取消
					</view>
					<view class="save" @click="saveQuick()">
						完成
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script src="./page.js">

</script>

<style scoped lang="scss">
	@import 'page.scss';
</style>
